# MI 测试工具启动脚本 (PowerShell)

Write-Host "========================================"
Write-Host "MI - 新一代测试工具"
Write-Host "========================================"
Write-Host ""

# Python路径
$pythonPath = "c:\work\code\cpt\.venv39\Scripts\python.exe"

# 检查Python
if (-not (Test-Path $pythonPath)) {
    Write-Host "错误: 未找到Python虚拟环境" -ForegroundColor Red
    Write-Host "请确保路径正确: $pythonPath"
    Read-Host "按回车键退出"
    exit 1
}

# 检查依赖
Write-Host "检查依赖..."
& $pythonPath -c "import PySide6; import numpy" 2>$null
if ($LASTEXITCODE -ne 0) {
    Write-Host ""
    Write-Host "警告: 缺少依赖包" -ForegroundColor Yellow
    Write-Host "正在安装 PySide6 和 numpy..."
    & $pythonPath -m pip install PySide6 numpy
}

Write-Host ""
Write-Host "启动 MI 测试工具..."
Write-Host ""

# 运行程序
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
& $pythonPath "$scriptDir\run_mi.py"

if ($LASTEXITCODE -ne 0) {
    Write-Host ""
    Write-Host "程序异常退出" -ForegroundColor Red
    Read-Host "按回车键退出"
}
